module Fabriq
  module CLI
    extend self

    attr_accessor :skype

    def skype
      @skype || Fabriq::Skype
    end

    def run(args)
      case args.first
      when "rooms"
        list_available_rooms
      end

      exit(0)
    end

    def list_available_rooms
      cli_out "\n*** Available Rooms: ***\n"
      
      skype.rooms.each do |room|
        topic = room.topic == "" ? "<not set>" : room.topic
        cli_out "* ID: %s\t Topic: %s" % [room.id, topic]
      end
    end


    private

    def cli_out(msg)
      puts msg
    end

  end
end